<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let num = +prompt('输入一个数字，你将获得从1到这个数字的累加和：')
        let i = 1
        let result = 0
        while (i <= num) {
            document.write(`这是第${i}个数字<br>`)
            result += i
            document.write(`结果为${result}<br>`)
            i++
        }
        alert(result)
    </script>
</body>

</html>